/*
 * Copyright (c) 2010. Dylan Schell.
 */

package nl.xs4all.dylanschell.deckprinter.transform;

import com.google.inject.Singleton;
import nl.xs4all.dylanschell.deckprinter.model.CardInDeck;
import nl.xs4all.dylanschell.deckprinter.model.DeckDescriptor;

@Singleton
public class ExplodeDeck implements DeckFilter
{
    public DeckDescriptor filter(DeckDescriptor input)
    {
        DeckDescriptor result = new DeckDescriptor(input.getName());
        for (String section : input.getSections())
        {
            for (CardInDeck card : input.getCardsInSection(section))
            {
                for (int i = 0; i < card.getQuantity(); i++)
                {
                    CardInDeck c = new CardInDeck(card.getName(), 1, card.getId());
                    result.getCardsInSection(section).add(c);
                }
            }
        }
        return result;
    }
}
